package Structure.array;

import java.util.Arrays;
import java.util.Random;

/**
 * @author wang'ji'cheng
 * @date 2025/7/26
 */
public class ArrayDemo4 {
    /**
     * 要求生成十个随机数，存入数组，
     * 求出总和，
     * 清楚平均数
     * @param args
     */
    public static void main(String[] args) {
        int [] arr = new int [10];
        Random r = new Random();
        for (int i = 0; i < arr.length; i++) {
            int num = r.nextInt(100)+1;
            arr[i]=num;
        }
        System.out.println(Arrays.toString(arr));
        int sum=0;
        for (int i = 0; i < arr.length; i++) {
            sum+=arr[i];
        }
        System.out.println("总和为"+sum);

        int avg = sum / arr.length;
        System.out.println("平均数为："+avg);

        int count = 0;
        for (int i = 0; i < arr.length; i++) {

            if(arr[i]<avg){
                count++;
            }
        }
        System.out.println("小于平均数的个数"+count);

    }
}
